| Conditions | 3 |
| Total Lines | 14 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { CommandHandler } from '@nestjs/cqrs'; |
||
| 16 | |||
| 17 | public async execute(command: DeleteEventCommand): Promise<void> { |
||
| 18 | const { id, user } = command; |
||
| 19 | const event = await this.eventRepository.findOneById(id); |
||
| 20 | |||
| 21 | if (!event) { |
||
| 22 | throw new EventNotFoundException(); |
||
| 23 | } |
||
| 24 | |||
| 25 | if (false === this.doesEventBelongToUser.isSatisfiedBy(event, user)) { |
||
| 26 | throw new EventDoesntBelongToUserException(); |
||
| 27 | } |
||
| 28 | |||
| 29 | await this.eventRepository.delete(event); |
||
| 30 | } |
||
| 32 |